package demo;


public class Test {
    //栈实现逆序打印链表
    public static void main(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.addLast(1);
        mySingleList.addLast(2);
        mySingleList.addLast(3);
        mySingleList.addLast(6);
        mySingleList.display2(mySingleList.head);
        System.out.println();
        mySingleList.display3();
/*        6 3 2 1
        6 3 2 1*/
    }
    public static void main5(String[] args) {
        MySingleList mySingleList = new MySingleList();

        mySingleList.addLast(1);
        mySingleList.addLast(2);
        mySingleList.addLast(3);
        mySingleList.addLast(6);
        mySingleList.display();
        System.out.println("-------翻转链表---------");
        MySingleList.ListNode listNode = mySingleList.reverseList();
        mySingleList.display(listNode);
    }
    public static void main4(String[] args) {
        MySingleList mySingleList = new MySingleList();

        mySingleList.addLast(45);
        mySingleList.addLast(45);
        mySingleList.addLast(45);
        mySingleList.addLast(45);
        mySingleList.display();
        System.out.println("----测试删除所有相同的元素-------");
        mySingleList.removeAllKey(45);
        mySingleList.display();
        System.out.println("---删除所有节点----");
        mySingleList.clear();
        mySingleList.display();
    }
    public static void main3(String[] args) {
        MySingleList mySingleList = new MySingleList();

        mySingleList.addLast(1);
        mySingleList.addLast(2);
        mySingleList.addLast(3);
        mySingleList.addLast(4);
        mySingleList.display();
        System.out.println("----测试删除-------");
        mySingleList.remove(38);
        mySingleList.display();


    }
    public static void main2(String[] args) {
        MySingleList mySingleList = new MySingleList();
        System.out.println("----测试插入----");
        mySingleList.addLast(1);
        mySingleList.addLast(2);
        mySingleList.addLast(3);
        mySingleList.addLast(4);
        //相当于头插
        mySingleList.addIndex(0,99);
        //相当于尾插
        mySingleList.addIndex(5,100);
        mySingleList.display();
    }
    public static void main1(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.createLink();
        mySingleList.display();
        System.out.println(mySingleList.contains(18));
        System.out.println("链表的长度:> "+mySingleList.size());
        mySingleList.addLast(50);
        mySingleList.addLast(70);

    }
}
